//==================================================================
//  Copyright (C) 2006  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
///
//==================================================================

#ifndef DEMO_SHADOWBUFFER_H
#define DEMO_SHADOWBUFFER_H

#include "rend_system.h"
#include "rendm5d.h"
#include "gxy.h"
#include "SkyBox.h"
#include "SeaBed.h"
#include "CamFly.h"
#include "ShadowTask.h"

class ShadowTask;
class TestShader;
class ShadowCastShader;

//==================================================================
///
//==================================================================
class ShadowBuffer
{
public:
	Window_SP						_winp;

	RendM5D::Scene					*_RScenep;
	RendDevice						*_RDevice;
	GXY::Context					*_mygxy_ctxap;

	M5D::Camera						*_Camerap;
	M5D::Light						*_SunLightp;
	PSYS::safe_ptr<SkyBox>			_skyboxp;
	PSYS::safe_ptr<SeaBed>			_seabedp;

	M5D::Model						*_plane_rootp;

	CamFly							_CameraFly;

	PSYS::safe_ptr<ShadowTask>		_shadow_taskp;
	PSYS::safe_ptr<TestShader>		_TestShaderp;
	PSYS::safe_ptr<ShadowCastShader>	_ShadowCastShaderp;

	ShadowBuffer() :
		_RScenep(NULL),
		_RDevice(NULL),
		_mygxy_ctxap(NULL),
		_plane_rootp(NULL)
	{
	}

	//==================================================================
	static int	handleWinEvent_s( void *objectp, WindowEvent::Type etype, Window::Event *eventp )
	{
		return ((ShadowBuffer *)objectp)->handleWinEvent( etype, eventp );
	}
	//==================================================================
	int	handleWinEvent( WindowEvent::Type etype, Window::Event *eventp );

	//==================================================================
	static int	handleMSWinEvent_s( void *objectp, class Window *T, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
	{
		return ((ShadowBuffer *)objectp)->handleMSWinEvent( T, hWnd, message, wParam, lParam );
	}
	//==================================================================
	int	handleMSWinEvent( class Window *T, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );

	//==================================================================
	void	doPaint( int vp_wd, int vp_he );
	void	onAnim();
	void	onCreation( Window *winp, int vp_wd, int vp_he );
	void	sceneFree();
	void	sceneAddSkybox();
};

#endif